package in

import "github.com/gogf/gf/net/ghttp"

var (
	Page  = "index" //页数
	Size  = "size"  //页/数
	Start = "start" //开始时间
	End   = "end"   //结束时间

	fnDealData = defDealData //返回数据处理,能修改返回结构
	fnSucc     = defFuncSucc //接口成功处理方法,能修改状态码和结构
	fnFail     = defFuncFail //接口失败处理方法,能修改状态码和结构

	codeSuccess interface{} = "SUCCESS" //code,成功
	codeFail    interface{} = "FAIL"    //code,失败
)

var (
	ExitHttpDone = "HTTP_DONE" //提前退出标识符
	ExitOk       = "OK"        //正常退出标识符
)

//设置分页参数字段
func SetPageSize(page, size string) {
	Page = page
	Size = size
}

//设置开始结束时间参数字段
func SetStartEnd(start, end string) {
	Start = start
	End = end
}

//设置正常退出字段
func SetExitOk(s string) {
	ExitOk = s
}

//设备返回结构
func SetDealData(fn func(bool, interface{}, ...int64) interface{}) {
	fnDealData = fn
}

//设置成功失败字段
//@succ,成功状态,例如"SUCCESS"
//@fail,失败状态,例如"FAIL"
func SetCode(succ, fail interface{}) {
	codeSuccess = succ
	codeFail = fail
}

//设置成功的数据处理
func SetFuncSucc(fn func(*ghttp.Request, interface{}, ...int64)) {
	fnSucc = fn
}

//设置失败的数据处理
func SetFuncFail(fn func(*ghttp.Request, interface{})) {
	fnFail = fn
}
